<?php
/**
 * @Author: EYong
 * @Date:   2018-05-11 11:48:59
 * @Last Modified by:   EYong
 * @Last Modified time: 2018-12-28 14:20:13
 */
namespace app\admin\validate;
use think\Validate;

/**
 * 行为验证器
 * @package app\admin\validate
 * @author amplam
 */
class Channel extends Validate {
	//定义验证规则
	protected $rule = [
		'channel_id'      => 'require|number|unique:bus_channel',
		'channel_id1'     => 'require',
		'company_name'    => 'require',
		'user_name'       => 'require',
		'overdraft_limit' => 'require',
		'key'             => 'require',
		'rechargenum'     => ['require', 'gt' => 0, 'regex' => '/^[0-9]+(.[0-9]{1,5})?$/'],
	];
	protected $message = [
		'channel_id.require'            => '渠道ID必填',
		'channel_id.number'             => '渠道ID必须为数字',
		'channel_id.unique:bus_channel' => '该渠道ID已存在',

		'channel_id1'                   => '渠道ID必填',
		'company_name'                  => '公司名称必填',
		'user_name'                     => '用户名必填',
		'overdraft_limit'               => '透支额度不能为空',
		'key'                           => '加密KEY不能为空',
		'rechargenum.require'           => '金额必填',
		'rechargenum.number'            => '金额必须是数字',
		'rechargenum'                   => '金额格式不正确',
	];
	//验证场景
	protected $scene = [
		'edt'         => ['company_name', 'channel_phone', 'key'],
		'channel_edt' => ['company_name'],
		'add'         => ['company_name', 'channel_phone'],
		'rec_add'     => ['channel_id1', 'rechargenum'],
		'rec_adjust'  => ['channel_id:require', 'rechargenum'],
	];

}
